package com.baizhi.serviceImpl;

import com.baizhi.dao.UserMapper;
import com.baizhi.entity.User;
import com.baizhi.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Resource
    UserMapper userMapper;

    String message = null;
    @Override
    public String query(User user) {

        QueryWrapper<User> wrapper = new QueryWrapper<>();
        QueryWrapper<User> eq = wrapper.eq("name", user.getName());
        User user1 = userMapper.selectOne(eq);
        // users.forEach(user2 -> System.out.println(user));
        //System.out.println(user1);
        if(user1!=null){
            if(user.getPassword().equals(user1.getPassword())){
                message="200";
            }else{
                message="密码错误";
            }
        }else{
            message="用户不存在";
        }
        return message;
    }

    @Override
    public void insert(User user) {

    }
}
